<%@ page language="java"  pageEncoding="UTF-8" errorPage="../error.jsp"%>
<%-- <%@ taglib prefix="s" uri="/struts-tags" %> --%>
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<%
	pageContext.setAttribute("ctx", request.getContextPath());	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>個人信息修改</title>
<link rel="stylesheet"  type="text/css" href="${ctx}/css/default.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/js/jqueryeasyui12/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/js/jqueryeasyui12/themes/icon.css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jqueryeasyui12/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jqueryeasyui12/locale/easyui-lang-zh_TW.js"></script>
<script type="text/javascript" src="${ctx}/js/ipebg/IPEBG.js"></script>
<script type="text/javascript" src="${ctx}/js/ipebg/COMMON.js"></script>
<style type="text/css">
input{
	font-family: Microsoft JhengHei,Microsoft YaHei,"黑体", Arial, Helvetica, sans-serif;
	color: #000000;
	padding-left: 5px;
}
</style>
<script type="text/javascript">
    var ctx = '${ctx}';
    jQuery(document).ready(function(){
    	
		$('#submit').click(function() {
			var validationResult = $("#addForm").form('validate');
	       	if(validationResult==false){
	       		$.messager.alert('系統提示','請輸入必填信息!','warning');
	       		return;
	       	}
		    $.messager.confirm('系統提示', '您確定需要提交嗎?', function(r) {
	            if (r) {	
	               	$.post(ctx +'/user.do?action=editUser',$("#addForm").serializeArray(),function(data){
	                   	if(data == "success"){
	     	                $.messager.alert('系統提示','修改成功!','info');
	                   	}else{
	                   		$.messager.alert('系統提示','修改失敗!','info');
	                   	}
	                });
	     	    }
			});
		    
		});
		
		//重置密碼提交
		$('#submitPwd').click(function() {
			
			var password = $("#pwd_password").val();
			var repassword = $("#pwd_repassword").val();
			if(password != repassword){
				$.messager.alert('系統提示','密碼和重複密碼不一致，請重新輸入!','warning');
				return false;
			}
			
			//保存和修改----------------------------
			var validationResult = $("#pwdForm").form('validate');
	       	if(validationResult==false){
	       		$.messager.alert('系統提示','請輸入必填信息!','warning');
	       		return;
	       	}
		    $.messager.confirm('系統提示', '您確定要重置密碼嗎?', function(r) {
	            if (r) {	
	               	$.post(ctx +'/user.do?action=modifyPwd',$("#pwdForm").serializeArray(),function(data){
	                   	if(data == "success"){
	                   		$("#optionWinModifyPwd").window('close');
	     	                $.messager.alert('系統提示','密碼重置成功!','info');
	                   	}else if(data == "pwderror"){
	                   		$.messager.alert('系統提示','舊密碼錯誤，請重新輸入!','info');
	                   		$("#old_password").val("");
	                   	}else{
	                   		$.messager.alert('系統提示','密碼重置失敗!','info');
	                   	}
	                });
	     	    }
			});
		    
		});
		//取消保存-------------------------
		$('#cancelPwd').click(function() {
	   	    $("#optionWinModifyPwd").window('close');
	    });
	});
	
	//重置密碼方法
	function modifyPwdOpen(){
		var optionWin = $("#optionWinModifyPwd");
		if (optionWin.is(':visible')){
		    ;
		}else{
			optionWin.slideDown();//显示 
		}
		optionWin.find("input").val("");
		var userId = $("#userId").val();
		optionWin.find("#pwd_userId").val(userId);
		optionWin.window('open');
	}
</script>
</head> 
<body>    
    <div style="width:99%">
		<div id="optionWin" class="easyui-panel" title="個人信息修改" 
		     style="width:400px;height:440px;padding:5px;left:60px;top:50px;background: #fafafa;" align="center">
			<form id="addForm" name="addForm" action="" method="post">
				<input type="hidden" id="userId" name="userId" value="${currentUser.adminId }"/>
	        	<table class="formTbl" style="font-size:13px">
	        	 	<tr>
						<th align="right" style="width:65px">工號：</th>
						<td>
						    <input type="text" id="jobNo" name="loginName" value="${currentUser.loginName }" onfocus="this.blur()" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;">
						</td>
					</tr>
					<tr>
						<th align="right">姓名：</th>
						<td>
						    <input id="realName" type="text" name="realName" value="${currentUser.realName }" onfocus="this.blur()" readonly="readonly" style="width:90%;color:#888;" class="easyui-validatebox">				 
						</td>
					</tr>
					<tr>
						<th align="right">部門：</th>
						<td>
							<input id="orgName" type="text" name="orgName" value="${orgName }" onfocus="this.blur()" readonly="readonly" style="width:90%;;color:#888;" class="easyui-validatebox"/>
						</td>
					</tr> 
					<tr>
						<th align="right">廠區：</th>
						<td>
							<c:if test="${currentUser.dominate == 'ZZK' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="鄭州綜保區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
						    <c:if test="${currentUser.dominate == 'ZZC' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="鄭州加工區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'JYX' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="濟源廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'JCX' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="晉城廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'LHX' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="龍華廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'GLX' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="觀瀾廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'HBX' }">
							<input name="dominate" id="dominate" onfocus="this.blur()" value="鶴壁廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
							<c:if test="${currentUser.dominate == 'NH' }">
								<input name="dominate" id="dominate" onfocus="this.blur()" value="內湖廠區(${currentUser.dominate })" readonly="readonly" class="easyui-validatebox" style="width:90%;color:#888;"/>
							</c:if>
						</td>
					</tr>
					<tr>
						<th align="right">电话：</th>
						<td>
						    <input id="phone" type="text" name="phone" value="${currentUser.phone }" style="width:90%" class="easyui-validatebox" required="true">
						    <font color="red">*</font>
						</td>
					</tr> 
					<tr>
						<th align="right">分机：</th>
						<td>
						    <input id="telePhone" type="text" name="telePhone" value="${currentUser.telePhone }" style="width:90%" class="easyui-validatebox" required="true" >				 
						    <font color="red">*</font>
						</td>
					</tr> 
					<tr>
						<th align="right">Email：</th>
						<td>
						    <input id="email" type="text" name="email" style="width:90%" value="${currentUser.email }"  class="easyui-validatebox" required="true" data-options="required:true,validType:'email'">
						    <font color="red">*</font>
						</td>
					</tr>
				</table>	
				<br>			
				<div style="padding:5px;text-align:center;">
					<a id="submit" href="#" class="easyui-linkbutton" icon="icon-ok">保存</a>
					&nbsp;&nbsp;&nbsp;
					<a href="#" class="easyui-linkbutton" onclick="modifyPwdOpen()" icon="icon-edit">修改密碼</a>
				</div>
			</form>
		</div>  
	</div>
	
	<div id="optionWinModifyPwd" class="easyui-window" title="修改密碼" closed="true" modal="true" 
	     collapsible="false" minimizable="false" maximizable="false" draggable="true" resizable="false"
	     style="width:400px;height:230px;padding:5px;left:60px;top:50px;background: #fafafa;display:none" align="">
		<form id="pwdForm" name="pwdForm" action="" method="post">
			<input type="hidden" id="pwd_userId" name="userId"/>
        	<table class="formTbl" style="font-size:13px">
        		<tr>
					<th align="right">舊密碼：</th>
					<td>
					    <input id="old_password" type="password" name="oldpassword" style="width:230px" class="easyui-validatebox" required="true">
					    <font color="red">*</font>
					</td>
				</tr>
				<tr>
					<th align="right">新密碼：</th>
					<td>
					    <input id="pwd_password" type="password" name="password" style="width:230px" class="easyui-validatebox" required="true">
					    <font color="red">*</font>
					</td>
				</tr>
				<tr>
					<th align="right">確認新密碼：</th>
					<td>
					    <input id="pwd_repassword" type="password" style="width:230px" class="easyui-validatebox"  required="true" >
					    <font color="red">*</font>
					</td>
				</tr>
			</table>	
			<br>			
			<div style="padding:5px;text-align:center;">
				<a id="submitPwd" href="#" class="easyui-linkbutton" icon="icon-ok">修改密碼</a>
				&nbsp;&nbsp;&nbsp;
				<a id="cancelPwd" href="#" class="easyui-linkbutton" icon="icon-cancel">取消</a>
			</div>
		</form>
	</div> 
  </body>
</html>